package com.alan.wlmediaplayer.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

import com.alan.wlmediaplayer.R;
import com.alan.wlmediaplayer.databinding.WlErrorViewBinding;
import com.lib.basex.widget.baselayout.LRelativeLayout;

/**
 * @author Alan
 * 时 间：11/3/21
 * 简 述：<功能简述>
 */
public class WlErrorView extends LRelativeLayout<String, WlErrorViewBinding> {
    public WlErrorView(Context context) {
        super(context);
    }

    public WlErrorView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public int getContentId() {
        return R.layout.wl_error_view;
    }

    @Override
    protected void initView(@Nullable AttributeSet attrs) {
        super.initView(attrs);
        setOnClickListener(v -> {

        });
    }

    public void setOnRetryListener(OnClickListener onRetryListener) {
        d.retryView.setOnClickListener(onRetryListener);
    }

    public void show(String title, String msg) {
        d.errorTitleView.setText(title);
        d.errorMsgView.setText(msg);
        setVisibility(View.VISIBLE);
    }

    public void show(String msg) {
        show("播放错误", msg);
    }

    public void hidden() {
        setVisibility(View.GONE);
    }
}
